<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\Relations\HasOne;
use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property string $content 内容
 * @property string $userId 用户编号
 * @property \Carbon\Carbon $created_at 添加日期
 * @property \Carbon\Carbon $updated_at 更新日期
 * @property int $isRoomMsg 是否是群消息 0 否 1是
 * @property int $direction 来源 1客户 0运营者
 * @property int $type 消息类型
 * @property int $readable 消息是否已读 0否 1是
 * @property int $is_send 是否发送 0 否 1是
 * @property int $status 是否正常 0 否 1是
 * @property int $account_id 服务账号id
 * @property string $add_time 添加时间毫秒
 */
class MessageTalk extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'message_talk';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'content', 'userId', 'created_at', 'updated_at', 'isRoomMsg', 'direction', 'type', 'readable', 'is_send', 'status', 'account_id', 'add_time'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'isRoomMsg' => 'integer', 'direction' => 'integer', 'type' => 'integer', 'readable' => 'integer', 'is_send' => 'integer', 'status' => 'integer', 'account_id' => 'integer'];
    /**
     * 获取运营号
     * @return HasOne
     */
    public function Operation() : HasOne
    {
        return $this->HasOne(WeworkOperation::class, 'marketUserId', 'marketUserId');
    }
    /**
     * 获取好友
     * @return HasOne
     */
    public function Friend() : HasOne
    {
        return $this->HasOne(WeworkFriend::class, 'userId', 'userId');
    }
}